const oracledb = require('oracledb');

let connection = null;
async function runDataBase(config) {
  console.log(config, 'config');
  oracledb.outFormat = oracledb.OUT_FORMAT_OBJECT;
  oracledb.initOracleClient();
  connection = await oracledb.getConnection(config);

  return true;
}

let closeDataBase = async () => {
  if (connection != null) {
    await connection.close();
  }
  return true;
};

let exectureSQL = async (SQLString) => {
  return await connection.execute(SQLString);
};

export { runDataBase, closeDataBase, exectureSQL };
